#define D2D_INPUT_COUNT 1
#define D2D_INPUT0_SIMPLE

#include "d2d1effecthelpers.hlsli"

float3 sourceColor;
float3 replaceColor;
float threshold;

D2D_PS_ENTRY(main)
{
	float4 sColor = D2DGetInput(0);
	float3 color = sColor.rgb;

	if (abs(color.r - sourceColor.r) < threshold && abs(color.g - sourceColor.g) < threshold && abs(color.b - sourceColor.b) < threshold)
	{
		//float3 newColor = color - sourceColor + replaceColor;
		float3 newColor =replaceColor;

		return float4(newColor.r, newColor.g, newColor.b, sColor.a);
	}
	else
	{
		return sColor;
	}
}
